package com.lbc.lock;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

//  测试线程池
public class TestPool {

    public static void main(String[] args) {
        //  1.创建线程池
        //  newFixedThreadPool 参数为：线程池的大小
        ExecutorService service = Executors.newFixedThreadPool(4);

        //  执行
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());
        Future<?> submit = service.submit(new MyThread());
        System.out.println("submit = " + submit);

        //  2.关闭连接
        service.shutdown();
    }

}

class MyThread implements Runnable {

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }
}